// 拍照识别，单个识别时展示病害详情
<template>
  <div class="box">
    <div class="app">
      <div class="left">
        <span>病害样图</span><br /><br />
        <!-- <img src="@/assets/apple-health.png" alt="" /> -->
        <img :src="dataDisease.img1" alt="" />
      </div>

      <div class="right">
        <h3>病情详情</h3>
        <el-collapse accordion>
          <el-collapse-item>
            <template slot="title">
              <h1 class="text2">为害症状</h1>
            </template>
            <div class="text">
              {{ dataDisease.symptom }}
            </div>
          </el-collapse-item>
          <el-collapse-item>
            <template slot="title">
              <h1 class="text2">病原物</h1>
            </template>
            <div class="text">
              {{ dataDisease.pathogen }}
            </div>
          </el-collapse-item>
          <el-collapse-item>
            <template slot="title">
              <h1 class="text2">侵染循环</h1>
            </template>
            <div class="text">
              {{ dataDisease.infectionCycle }}
            </div>
          </el-collapse-item>
          <el-collapse-item>
            <template slot="title">
              <h1 class="text2">发生因素</h1>
            </template>
            <div class="text">
              {{ dataDisease.occurrenceFactor }}
            </div>
          </el-collapse-item>
          <el-collapse-item>
            <template slot="title">
              <h1 class="text2">防治方法</h1>
            </template>
            <div class="text">
              {{ dataDisease.preventionMethod }}
            </div>
          </el-collapse-item>
        </el-collapse>
      </div>
    </div>
  </div>
</template>
<script>
import { plantDetil } from "@/api/index";
export default {
  data() {
    return {
      dataDisease: {},
    };
  },
  computed: {
    status() {
      //  计算属性，获取病害名称
      return this.$store.state.disease; //  Vuex 中定义的属性
    },
  },
  watch: {
    //监听计算属性status的值
    status(newData, oldData) {
      console.log("oldData==" + oldData);
      console.log("newData==" + newData);
      this.initInfo(); //   需要调用的方法
    },
  },
  methods: {
    initInfo() {
      let disease = this.$store.state.disease;
      // console.log("disease====" + disease);
      if (disease != "" || disease != null) {
        plantDetil(disease).then((res) => {
          // console.log("res========" + JSON.stringify(res.data));
          this.dataDisease = JSON.parse(JSON.stringify(res.data)).data;
        });
      }
    },
  },
};
</script>
<style scoped>
.box {
  width: 200px;
  height: 300px;
  /* background-color: black; */
}
.a {
  font-size: 30px;
}
.app {
  width: 1000px;
  margin: auto;
  border: solid lpx rgb(226, 226, 226);
  margin-left: 150px;
}
.left {
  float: left;
  width: 300px;
  height: 600px;
  margin-top: 40px;
}
div img {
  width: 100%;
  display: block;
  width: 200px;
  height: 200px;
}
.right {
  float: left;
  width: 600px;
  height: 300px;
  margin-right: 30px;
  margin-top: 20px;
}
.myp {
  background: aqua;
  width: 500px;
}
.text {
  font-size: 18px;
}
.title {
  font-size: 30px;
}
.text2 {
  font-size: 24px;
  color: rgb(0, 49, 37);
}
</style>
